package mtn.bowen.yan.server.enums;

/**
 * @author <a href=mailto:yanbowen90@foxmail.com> bowen.yan </a>
 * @version 1.0
 * @description: TODO
 * @date 2021-10-22 10:42 AM
 */
public enum ErrorCode {
    /**
     * 成功
     */
    SUCCESS(0, "success"),

    /**
     * 系统异常
     */
    SYSTEM_EXCEPTION(1000, "系统异常！"),

    ;

    ErrorCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @SuppressWarnings("unused")
    public static ErrorCode forCode(Integer code) {
        for (ErrorCode type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }

    private Integer code;

    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}